//
//  ReportListCell.m
//  suRead
//
//  Created by lidi on 15/11/11.
//  Copyright © 2015年 bao. All rights reserved.
//

#import "ReportListCell.h"
#import "M_Report.h"
#import "UIImageView+WebCache.h"
#import "AccountManager.h"

@interface ReportListCell()
@property (weak, nonatomic) IBOutlet UIImageView *imageViewIcon;
@property (weak, nonatomic) IBOutlet UILabel *labelTitle;
@property (weak, nonatomic) IBOutlet UILabel *labelTime;
@property (strong, nonatomic) IBOutlet UILabel *commentsLable;
@property (strong, nonatomic) IBOutlet UILabel *stateLable;
@property (strong, nonatomic) IBOutlet UILabel *zanLable;
@property (weak, nonatomic) IBOutlet UIView *viewCountContainer;

@end

@implementation ReportListCell

- (void)awakeFromNib {
    // Initialization code
    [super awakeFromNib];
}

- (void)setReportData:(M_Report *)reportData
{
    [self.imageViewIcon sd_setImageWithURL:[NSURL URLWithString:reportData.f_thumb] placeholderImage:[UIImage imageNamed:@"report_lazy"]];
    self.labelTitle.text = reportData.f_title;
    self.labelTime.text = reportData.f_inputtime;
    
    self.stateLable.layer.masksToBounds = YES;//没这句话它圆不起来
    self.stateLable.layer.cornerRadius  = 3.0;//设置图片圆角的尺度
    switch (reportData.f_replystate) {
        case 0://待处理
        {
            [self.stateLable setText:@" 待处理 "];
            [self.stateLable setBackgroundColor:[UIColor colorWithRed:0xb1 / 255.0f green:0x25 / 255.0f blue:0x24 / 255.0f alpha:1]];
        }
            break;
        case 1://处理中
        {
            [self.stateLable setText:@" 处理中 "];
            [self.stateLable setBackgroundColor:[UIColor colorWithRed:0xdd / 255.0f green:0xa3 / 255.0f blue:0x28 / 255.0f alpha:1]];
        }
            break;
        case 2://已处理
        {
            [self.stateLable setText:@" 已处理 "];
            [self.stateLable setBackgroundColor:[UIColor colorWithRed:0x71 / 255.0f green:0xbb / 255.0f blue:0x89 / 255.0f alpha:1]];
        }
            break;
        default:
            break;
    }
    
    if ([AccountManager sharedAccountManager].f_isShowViewCount) {
        self.viewCountContainer.hidden = NO;
        [self.commentsLable setText:[NSString stringWithFormat:@"%ld",reportData.f_comments]];
        [self.zanLable setText:[NSString stringWithFormat:@"%ld",reportData.f_square]];
    } else {
        self.viewCountContainer.hidden = YES;
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
